//引用Vuex
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

//实例store对象
const store = new Vuex.Store({
	state: {
		userInfo: null,
		sysAllDictItems: {},
		isFoodStore: ""
	},
	mutations: {
		logout(state) {
			uni.setStorageSync("token", null)
			state.userInfo = null
		},
		setUserInfo(state, data) {
			state.userInfo = data
		},
	},
	actions: {
		setUserInfo(context, data) {
			context.commit('setUserInfo', data)
		},
		logout(context) {
			context.commit('logout')
		},
	},
	getters: {
		getUserInfo(state) {
			let userInfo = state.userInfo || uni.getStorageSync("userInfo")
			return userInfo || ''
		}
	}
})

//导出store对象
export default store